package com.example.modulethree.activity

import android.os.Bundle
import android.view.View
import com.example.modulethree.R
import com.example.modulethree.binder.KotlinTestLayoutBinder
import com.example.modulethree.delegate.KotlinMVPTestActivityDelegate
import com.example.mvp.activity.BaseMVPActivity
import com.example.mvp.binder.BaseDataBinder

/**
 * Created by sun.li on 2018/6/27.
 * @author sun.li
 */
class KotlinMVPTestActivity : BaseMVPActivity<KotlinMVPTestActivityDelegate>(){

    var hint : String = ""

    var index : Int = 0

    override fun initDate() {
        hint = "我是初始化内容"
    }

    override fun bindEvenListener() {
        viewDelegate?.setOnClickListener(View.OnClickListener {
            finish()
        },R.id.tv_kta_text)

        viewDelegate?.setOnClickListener(View.OnClickListener {
            hint = if(index<1)"内容第一次变" else "屏幕戳爆内容也不会变"
            notifyModelChanged(hint)
            index++
        },R.id.bt_kta_alter)
    }

    override fun getDelegateClass(): Class<KotlinMVPTestActivityDelegate> {
        return KotlinMVPTestActivityDelegate::class.java
    }

    override fun getDataBinder(): BaseDataBinder<*, *> {
        return KotlinTestLayoutBinder()
    }

    override fun initView(p0: Bundle?) {
        notifyModelChanged(hint)
    }

}